package com.example.rabbit.config;

import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/*@Configuration*/
public class BindingConfig {
    @Autowired
    ExchangeConfig exchange;

    @Autowired
    MyQueueConfig queue;

    @Bean
    public Binding bindFanout1() {
        return BindingBuilder.bind(queue.loginfo()).to(exchange.fanoutExchange());
    }
    @Bean
    public Binding bindFanout2() {
        return BindingBuilder.bind(queue.logerror()).to(exchange.fanoutExchange());
    }
/*---------------------------*/
    @Bean
    public Binding bindDirect() {
        return BindingBuilder.bind(queue.loginfo()).to(exchange.directExchange()).with("log.info.routing.key");
    }
    @Bean
    public Binding bindDirect2() {
        return BindingBuilder.bind(queue.logerror()).to(exchange.directExchange()).with("log.error.routing.key");
    }

    /*---------------------------*/
    @Bean
    public Binding bindTopic1(){
        Binding binding= BindingBuilder.bind(queue.logall()).to(exchange.topicExchange()).with("*.orange.*");
        return binding;
    }
    @Bean
    public Binding bindTopic2(){
        Binding binding= BindingBuilder.bind(queue.logerror()).to(exchange.topicExchange()).with("*.log.error");
        return binding;
    }
    @Bean
    public Binding bindTopic3(){
        Binding binding= BindingBuilder.bind(queue.loginfo()).to(exchange.topicExchange()).with("*.orange.info");
        return binding;
    }

}
